home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / COLOR.BAT < prev    next >
DOS Batch File  |  1990-10-21  |  3KB  |  104 lines

  1. echo off
  2. echo 
  3. echo 
  4. echo H┌───────────────────────────────────────────────────┐
  5. echo │ Set screen color attributes                       │
  6. echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 21-Oct-90 │
  7. echo └───────────────────────────────────────────────────┘
  8. echo.
  9.  
  10. rem If you get an "Out of environment space" message, increase your
  11. rem environment space by using shell configuration in config.sys:
  12. rem MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p
  13.  
  14. rem If no parameters, show the color table
  15. if "%1"=="" goto _help
  16.  
  17. rem Make the TextColor parameter uppercase
  18. set tmp_=%path%
  19. path=%1
  20. set upcase1_=%path%
  21. path=%tmp_%
  22.  
  23. rem Make the BackgroundColor parameter uppercase
  24. set upcase2_=
  25. if "%2"=="" goto _assign
  26. set tmp_=%path%
  27. path=%2
  28. set upcase2_=%path%
  29. path=%tmp_%
  30.  
  31. :_assign
  32. rem Set the appropriate ansi codes into variables
  33. set text_=InvalidTextColor
  34. for %%n in (0 BLACK) do if "%%n"=="%upcase1_%" set text_=
  35. for %%n in (1 BLUE) do if "%%n"=="%upcase1_%" set text_=
  36. for %%n in (2 GREEN) do if "%%n"=="%upcase1_%" set text_=
  37. for %%n in (3 CYAN) do if "%%n"=="%upcase1_%" set text_=
  38. for %%n in (4 RED) do if "%%n"=="%upcase1_%" set text_=
  39. for %%n in (5 MAGENTA) do if "%%n"=="%upcase1_%" set text_=
  40. for %%n in (6 BROWN) do if "%%n"=="%upcase1_%" set text_=
  41. for %%n in (7 LIGHTGRAY) do if "%%n"=="%upcase1_%" set text_=
  42. for %%n in (9 LIGHTGBLUE) do if "%%n"=="%upcase1_%" set text_=
  43. for %%n in (10 LIGHTGREEN) do if "%%n"=="%upcase1_%" set text_=
  44. for %%n in (11 LIGHTCYAN) do if "%%n"=="%upcase1_%" set text_=
  45. for %%n in (12 LIGHTRED) do if "%%n"=="%upcase1_%" set text_=
  46. for %%n in (13 LIGHTMAGENTA) do if "%%n"=="%upcase1_%" set text_=
  47. for %%n in (14 YELLOW) do if "%%n"=="%upcase1_%" set text_=
  48. for %%n in (15 WHITE) do if "%%n"=="%upcase1_%" set text_=
  49.  
  50. if not "%2"=="" set back_=InvalidBckColor
  51. for %%n in (0 BLACK) do if "%%n"=="%upcase2_%" set back_=
  52. for %%n in (1 BLUE) do if "%%n"=="%upcase2_%" set back_=
  53. for %%n in (2 GREEN) do if "%%n"=="%upcase2_%" set back_=
  54. for %%n in (3 CYAN) do if "%%n"=="%upcase2_%" set back_=
  55. for %%n in (4 RED) do if "%%n"=="%upcase2_%" set back_=
  56. for %%n in (5 MAGENTA) do if "%%n"=="%upcase2_%" set back_=
  57. for %%n in (6 BROWN) do if "%%n"=="%upcase2_%" set back_=
  58. for %%n in (7 LIGHTGRAY) do if "%%n"=="%upcase2_%" set back_=
  59.  
  60. rem Were the color parameters valid
  61. if "%text_%"=="InvalidTextColor" goto _err1
  62. if "%back_%"=="InvalidBckColor" goto _err2
  63.  
  64. rem Set the new color attributes and clear the screen
  65. echo %text_%
  66. if not "%back_%"=="" echo %back_%
  67. echo 
  68. goto _out
  69.  
  70. :_err1
  71. echo Invalid TextColor %1
  72. goto _out
  73.  
  74. :_err2
  75. echo Invalid BackgroundColor %2
  76. goto _out
  77.  
  78. :_help
  79. echo Usage: COLOR TextColor[orNumber] [BackgroundColor[orNumber]]
  80. echo.
  81. echo 0 Black
  82. echo 1 Blue
  83. echo 2 Green
  84. echo 3 Cyan
  85. echo 4 Red
  86. echo 5 Magenta
  87. echo 6 Brown
  88. echo 7 LightGray
  89. echo 9 LightBlue
  90. echo 10 LightGreen
  91. echo 11 LightCyan
  92. echo 12 LightRed
  93. echo 13 LightMagenta
  94. echo 14 Yellow
  95. echo 15 White
  96. goto _out
  97.  
  98. :_out
  99. set upcase1_=
  100. set upcase2_=
  101. set text_=
  102. set back_=
  103. echo on
  104.